﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using txlcinfo.DSKH.Dtos;
using txlcinfo.DSKH.Users;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace txlcinfo.DSKH
{
    public class WxUserAppservice : CrudAppService<
            WeixinUser, //The Book entity
            WxUserDto, //Used to show books
            Guid, //Primary key of the book entity
            PagedAndSortedResultRequestDto, //Used for paging/sorting
            CreateUpdateWxUserDto>, //Used to create/update a book
        IWxUserAppservice //implement the IBookAppService
    {
        private readonly IRepository<WeixinUser, Guid> _repository;
        public WxUserAppservice(IRepository<WeixinUser, Guid> repository)
            : base(repository)
        {
            _repository = repository;
        }

        public async Task<WxUserDto> GetUserBywxIdAsync(string wxid)
        {
            var allentity = await _repository.GetListAsync();
            var selected = allentity.FirstOrDefault(p => p.WeixinID == wxid);
            return ObjectMapper.Map<WeixinUser, WxUserDto>(selected);

        }
    }
}
